package actions;

import gui.GUIWindow;

import java.awt.event.ActionEvent;

import server.RLM_Server;


@SuppressWarnings("serial")
public class ExitAction extends SysTrayAbstractAction {

	public ExitAction(GUIWindow owner) {
		setActionOwner(owner);
		
//		putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0));
//		putValue(SMALL_ICON, ImageCreator.createImageIcon(AboutAction.class, "images/exit.png"));
		putValue(NAME, "Exit");
		putValue(SHORT_DESCRIPTION, "Exit");
		
		setActionItem();
	}
	
	
	public void actionPerformed(ActionEvent e) {

		RLM_Server serverReference = null;
		
		if ( getActionOwner() != null ) {
			serverReference = getActionOwner().getApplication().getRlmServerReference();
		}
		
		if ( serverReference != null ) {
			if ( serverReference.isStarted() ) {
				serverReference.stopServer();
			}
		}
		

//		UpdateServerParameters.storeParameters();
		
		if ( getActionOwner() != null ) {
			getActionOwner().getActionManager().setStoppedRights();
			getActionOwner().setVisible(false);
			getActionOwner().dispose();
		}
		
		System.exit(0);
	}
	
	
}
